import { Message } from 'element-ui'
import { MessageBox } from 'element-ui';
export function info(msg) {
    Message({
        type: 'info',
        message: `${msg}`,
        duration: 1500
    })
}
export function success(msg) {
    Message({
        type: 'success',
        message: `${msg}`,
        duration: 1500
    })
}

export function warn(msg) {
    Message({
        type: 'warning',
        message: `${msg}`,
        duration: 1500
    })
}

export function error(msg) {
    Message({
        type: 'error',
        message: `${msg}`,
        duration: 1500
    })
}
export function confirm(msg, title = '', type = 'warning', confirmButtonText = '确定', cancelButtonText = '取消'){
    return new Promise((resolve,reject)=>{
        MessageBox.confirm(msg, title, {
            confirmButtonText: confirmButtonText,
            cancelButtonText: cancelButtonText,
            type: type,
            callback: (action) => {
                action = action+''
                if(action === 'confirm'){
                    resolve()
                }else{
                    reject('取消操作')
                }
            }
        })
    })
}